<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="Dayu" content="created by dayu"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="Dayu" content="Created by Dayu">
    <title>用户注册</title>
    <link rel="stylesheet" href="/static/frontend/css/login.css"/>
    <script src="/static/frontend/js/jquery-1.10.1.js"></script>
</head>
<body class="register_page">
<div class="regist">
    <div class="regist_center">
        <div class="logo">
            <!-- <img src="/static/frontend/image/loge_nft.jpg" alt="My Go Mall"> -->
        </div>
        <div class="regist_top">
            <h2>注册NFT Cosmos账户</h2>
        </div>
        <div class="regist_main center">
            <!-- jquery通过name获取对应输入的值 -->
            <input class="form_input" type="text" name="phone" id="phone" placeholder="请填写正确的手机号"/>
            <div class="yzm">
                <input type="text" id="phone_code" name="phone_code" placeholder="请输入图形验证码"/>
            {{create_captcha}}
            </div>
            <div class="error"></div>
            <div class="regist_submit">
                <button class="submit" id="registerButton">
                    立即注册
                </button>
            </div>
            <br>
            <br>
            <div class="privacy_box">
                <div class="msg">
                    <label class="n_checked now select-privacy">
                        <input type="checkbox" checked="true"/>注册账户即表示您同意并遵守NFT Cosmos的规则
                        <a href="https://localhost:8080/leastmall/agreenment/account/cn.html"
                        class="inspect_link" title="用户协议" target="_blank">用户协议</a>和<a
                        href="http://localhost:8080/about/privacy/" class="inspect_link privacy_link"
                        title="隐私政策" target="_blank">隐私政策</a>
                    </label>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function(){

        $("#registerButton").click(function(){
            var phone = $('#phone').val();
            // phone_code是图形验证码
            var phone_code = $('#phone_code').val(); 
            var phoneCodeId = $("input[name='captcha_id']").val();

            var reg = /^[\d]{11}$/;
            if (!reg.test(phone)){
                $(".error").html("Error:手机号输入错误");
                return false;
            }

            if (phone_code.length < 4){ //因为给的验证码图片包含的照片都是4位
                $(".error").html("Error:图形验证码长度不合法");
                return false;
            }

            $.get('/auth/sendCode',{
                phone:phone,
                phone_code:phone_code,
                phoneCodeId:phoneCodeId
            },function (response){
                console.log(response)
                    if (response.success == true){
                        location.href="/auth/registerStep2?sign="+response.sign+"&phone_code="+phone_code;

                    }else{
                        $(".error").html("Error:"+response.msg+",请重新输入！")

                        var captchaImgSrc=$(".captcha-img").attr("src")
                        $("#phone_code").val("") //设置对应input框的值
                        $(".captcha-img").attr("src",captchaImgSrc + "?reload" + (new Data()).getTime())
                    }

            })
        })
    })
</script>
</body>
</html>